#!/bin/sh
if [ -n "$1" ]
then
	CASSDK_HOME=$1
else
	##没有指定安装路径时，指定默认的路径
	CASSDK_HOME="/usr/local/cassdk"
fi

CASSDK_HOME_LIB="$CASSDK_HOME/bin"
echo "uninstall from CASSDK.............................."
# 删除安装目录
rm -frv  $CASSDK_HOME
## 删除conf
rm -fv /etc/ld.so.conf.d/cassdk_lib.conf
/sbin/ldconfig

##更新profile 
lib_reg_path=`echo $CASSDK_HOME_LIB|sed -r 's/([\/\.])/\\\\\1/g'`
home_reg_path=`echo $CASSDK_HOME|sed -r 's/([\/\.])/\\\\\1/g'`
echo delete the line if exist:
echo \"export LD_LIBRARY_PATH=$CASSDK_HOME_LIB:\$LD_LIBRARY_PATH\"
echo \"export CASSDK_HOME=$CASSDK_HOME\"
sed -i_bak -r "/^\s*export\s*LD_LIBRARY_PATH=$lib_reg_path:\\\$LD_LIBRARY_PATH/d" /etc/profile 		
sed -i_bak -r "/^\s*export\s*CASSDK_HOME\s*=$home_reg_path/d" /etc/profile
echo "uninstall finished"

